package com.koron.order.maintain.controller;

import com.koron.bean.base.Response;
import com.koron.order.common.bean.dto.OrderDispatchDto;
import com.koron.order.common.controller.OrderDispatchController;
import com.koron.order.maintain.bean.entity.MaintainStatus;
import com.koron.order.maintain.service.MaintainDispatchService;
import com.koron.order.maintain.service.MaintainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * (Maintain)表控制层
 *
 * @author zhouj
 * @since 2021-09-13 17:42:15
 */
@Api(tags = "日常维护工单-派工信息")
@RestController
@RequestMapping("/maintain/dispatch/")
public class MaintainDispatchController extends OrderDispatchController {

    @Autowired
    private MaintainDispatchService dispatchService;

    @Autowired
    private MaintainService maintainService;

    @Override
    @ApiOperation(value = "新增或更新")
    @PostMapping("saveDispatchInfo")
    public Response<String> saveDispatchInfo(@RequestBody OrderDispatchDto dto) {
        Response<String> response = super.saveDispatchInfo(dto);
        if (dto.getIsCommit()) {
            //修改工单状态 待派工-->待执行
            String orderId = dto.getOrderId();
            Integer submitMaintain = ADOConnection.runTask(getCurrDs(), maintainService, "submitMaintain", Integer.class, orderId, MaintainStatus.WAIT_EXECUTE.getStatus(), dto);
        }
        return Response.ok(response.getData());
    }

}